<template>
  <div>
    <TableList :records="records" @docOpen="docOpen" @xianshi="xianshi" />
    <Detail v-show="isAll" :single="single" @docClose="isAll = false" />
  </div>
</template>

<script>
import TableList from '@/components/TableList.vue'
import Detail from '@/components/Detail.vue'

export default {
  components: { TableList, Detail },
  data() {
    return {
      records: [
        {
          date: '2022-01-01',
          doctor: '张三',
          diagnosis: '感冒',
          prescription: '感冒药',
        },
        {
          date: '2022-02-01',
          doctor: '李四',
          diagnosis: '头疼',
          prescription: '止疼药',
        },
        {
          date: '2022-03-01',
          doctor: '王五',
          diagnosis: '腰痛',
          prescription: '止痛贴',
        },
      ],
      // list: [],
      single: {},
      isAll: false,
    }
  },
  methods: {
    docOpen(item) {
      this.single = item
      this.isAll = true
    },

    xianshi(value) {
      console.log(value)
      if (value) {
        this.records = this.records.filter((item) => {
          return item.doctor === value
        })
      } else {
        this.records = this.records
      }
    },
  },
}
</script>

<style></style>
